<%@ page language="java" isELIgnored="false" import="java.util.*"
	pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<title>添加资源</title>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<link rel="stylesheet" type="text/css"
			href="${pageContext.request.contextPath}/css/pingTai/pingTai.css">
		<script src="${pageContext.request.contextPath}/js/utils.js"
			type="text/javascript" language="javascript">
</script>
		<SCRIPT type="text/javascript" language="javascript"
			src="${pageContext.request.contextPath}/js/jquery-1.7.2.js"></SCRIPT>
		<script type="text/javascript">
		$(document).ready(function() {
			$('#_select').change(function() {
				if($(this).val() == 'y') {
					$('#_pointout').text("请选择文件:");
					$('#_parent').empty();
					$('#_parent').append('<input type="file" name="path" id="_localFile">');
				} else {
					$('#_pointout').text("请填写正确的URL:");
					$('#_parent').empty();
					$('#_parent').append('<input type="text" name="path" id="_urlFile" size="60">');
				}	
			});
		});
</script>
		<script charset="utf-8"
			src="${pageContext.request.contextPath}/editor/kindeditor.js">
</script>
		<script charset="utf-8"
			src="${pageContext.request.contextPath}/editor/lang/zh_CN.js">
</script>
<script>
		var editor;
		KindEditor.ready(function(K) {
			editor = K.create('textarea[name="description"]', {
				cssPath : '${pageContext.request.contextPath}/editor/plugins/code/prettify.css',
				uploadJson : '${pageContext.request.contextPath}/admin/editor/upload',
				fileManagerJson : '${pageContext.request.contextPath}/admin/editor/manager',
				allowFileManager : true
			});
			prettyPrint();
		});
	</script>
	</head>
	<body>
		<table width="100%" border="0" align="center" cellpadding="0"
			cellspacing="0">
			<tr>
				<td height="3"></td>
			</tr>
			<tr height="20" valign="baseline">
				<td bgcolor="#353c44">
					<img src="${pageContext.request.contextPath}/images/pingTai/tb.gif"
						width="14" height="14" />
					<span class="STYLE1">添加资源</span>
				</td>
				<td align="right" bgcolor="#353c44">
					<span class="STYLE1"> </span>
				</td>
			</tr>
			<tr>
				<td height="3" colspan="2"></td>
			</tr>
		</table>

		<form
			action="${pageContext.request.contextPath}/admin/resource/add"
			method="post" id="_form" enctype="multipart/form-data" id="_form">
			<table width="100%" border="0" cellpadding="0" cellspacing="1"
				bgcolor="#a8c7ce">

				<tr bgcolor="#FFFFFF" class="STYLE19">
					<td align="right" width="15%">
						资源名:
					</td>
					<td width="35%">
						<input type="text" name="name" id="_name" size="60" />
					</td>
					<td align="right">
						仅允许会员下载:
					</td>
					<td>
					<input type="checkbox" name="isPri">
					</td>
				</tr>
				<tr bgcolor="#FFFFFF" class="STYLE19">
					<td align="right" width="15%">
						资源类型:
					</td>
					<td width="35%">
						<select name="isLocal" id="_select">
								<option selected="selected" value="y">本地文件</option>
								<option value="n">网络url</option>
							</select>
					</td>
					<td align="right">
						<div id="_pointout">请选择文件:</div>
					</td>
					<td id="_parent">
						<input type="file" name="path" id="_localFile">
					</td>
				</tr>
				<tr bgcolor="#FFFFFF" class="STYLE19">
					<td align="center" width="100%" colspan="4">
						<table>
							<tr bgcolor="#FFFFFF" class="STYLE19">
								<td width="15%" align="right">
									资源描述:
								</td>
								<td>
									<textarea id="editor_id" name="description"
										style="width: 800px; height: 400px;">
									</textarea>
								</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr bgcolor="#FFFFFF" class="STYLE19">
					<td colspan="4" align="center">
						<input type="button" class="button2" value="添加" onclick="validatewhere();"
							 />
						<input type="reset" class="button2" value="重置" />
						<input type="button" class="button2" value="返回"
							onclick="javascript:history.go(-1);" />
					</td>
				</tr>
			</table>
		</form>
	</body>
	<script type="text/javascript">
		function validatewhere() {
			var name = $('#_name').val();
			if(!utils_stringLength(name, '资源名', 2, 80))
				return;
			var urlFile = $('#_urlFile').val();
			if(urlFile == null) {
				var localFile = $('#_localFile').val();
				if(localFile.length == 0) {
					alert('未选择资源文件！');
					return;
				}
				$('#_form').submit();
			} else {
				if(!utils_url(urlFile,"url"))
					return;
				$('#_form').submit();
			}
		}
	</script>
</html>
